<template>
  <div class="demo">
    <template>
      <div v-if="mode === 'edit'">
        <van-nav-bar
          :title="barTitle"
          :left-text="barLeftText"
          :right-text="barRightText"
          left-arrow
          @click-left="onClickLeft"
          @click-right="onClickRight"
        />
      </div>
      <div v-else>{{ value }}</div>
    </template>
  </div>
</template>

<script>
import { Toast } from "vant";
import datasource from "../../mixins/steps-datasource";
export default {
  name: "navMenu",
  mixins: [datasource],
  components: {},
  props: {
    value: {},
    mode: {
      default: "edit", // 编辑模式和 edit， 展示模式 view
    },
    readonly: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    barTitle: {
      default: "",
    },
    barLeftText: {
      default: "",
    },
    barRightText: {
      default: "",
    },
  },
  data() {
    return {
      barTitle: "标题",
      barLeftText: "返回",
      barRightText: "主页",
    };
  },
  computed: {},
  watch: {
    options: {
      immediate: true,
      deep: true,
      handler(val) {
        if (val && val.length) {
          this.menuList = val.map((item) => {
            return {
              value: item._data.value,
              title: item._data.title,
            };
          });
        }
      },
    },
  },
  created() {},
  mounted() {
    // if (this.value) {
    //   this.phoneNum = this.value;
    //   if (this.mode == "view") {
    //     this.disabled = true;
    //   }
    // }
  },
  methods: {
    onClickLeft() {
      Toast(this.barLeftText);
    },
    onClickRight() {
      Toast(this.barRightText);
    },
  },
};
</script>
<style lang="scss" scoped>
.demo {
  width: 100%;
  .van-cell {
    padding: 0;
  }
  .van-nav-bar__text {
    color: #fff !important;
  }
}
</style>
